﻿namespace B.R.RabbitRoot.ErrorCode
{
    /// <summary>
    /// 返回信息
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class APIResult<T> 
    {
        /// <summary>
        /// 返回码
        /// </summary>
        public ResultCode Code { get; set; }
        public int CodeNew { get; set; }
        /// <summary>
        /// 返回信息
        /// </summary>
        public string Message { get; set; }
        /// <summary>
        /// 实体
        /// </summary>
        public T Data { get; set; }
        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public APIResult<T> Success(T data)
        {
            return new APIResult<T>()
            {
                CodeNew =200,
                Data = data,
                Message = "成功"
            };
        }
        /// <summary>
        /// 失败
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public APIResult<T> Error(string message)
        {
            return new APIResult<T>()
            {
                CodeNew = 500,
                Data = default,
                Message = "成功"
            };
        }
    }
}
